<?php
/**
 * Created by PhpStorm.
 * User: sunzexin
 * Date: 2018/2/11
 * Time: 16:37
 */

namespace App\Http\Controllers\MiniProgram;


use App\Http\Logics\MiniProgram\RecruitmentLogic;
use App\Http\Traits\RecruitmentTrait;
use App\Http\Controllers\BaseController;
class RecruitmentController extends BaseController
{
    use RecruitmentTrait;

    /**
     * @SWG\Post(
     *     path="/recruitment/create",
     *     tags={"Recruitment"},
     *     description="创建招聘信息",
     *     operationId="createRecruitment",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="cafe_id",
     *         in="query",
     *         description="咖啡馆ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="title",
     *         in="query",
     *         description="招聘标题",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="post",
     *         in="query",
     *         description="招聘岗位",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="number",
     *         in="query",
     *         description="招聘人数",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="type",
     *         in="query",
     *         description="招聘类型",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="salary",
     *         in="query",
     *         description="工资",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="sex",
     *         in="query",
     *         description="性别要求",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="experience",
     *         in="query",
     *         description="经验要求",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="remark",
     *         in="query",
     *         description="备注",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function createRecruitment()
    {
        $cafe_id = $this->cafe_id;
        $title = $this->title;
        $post = $this->post;
        $number = $this->number;
        $type = $this->type;
        $salary = $this->salary;
        $work_time = $this->work_time;
        $sex = $this->sex;
        $education = $this->education;
        $experience = $this->experience;
        $remark = $this->remark;
        $data = [
            'cafe_id' => $cafe_id,
            'title' => $title,
            'post' => $post,
            'number' => $number,
            'type' => $type,
            'salary' => $salary,
            'sex' => $sex,
            'experience' => $experience,
            'remark' => $remark
        ];
        $response = RecruitmentLogic::createRecruitment($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/recruitment/update",
     *     tags={"Recruitment"},
     *     description="更新招聘信息",
     *     operationId="updateRecruitment",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="recruitment_id",
     *         in="query",
     *         description="招聘信息ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="title",
     *         in="query",
     *         description="招聘标题",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="post",
     *         in="query",
     *         description="招聘岗位",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="number",
     *         in="query",
     *         description="招聘人数",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="type",
     *         in="query",
     *         description="招聘类型",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="salary",
     *         in="query",
     *         description="工资",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="sex",
     *         in="query",
     *         description="性别要求",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="experience",
     *         in="query",
     *         description="经验要求",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="remark",
     *         in="query",
     *         description="备注",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function updateRecruitment()
    {
        $recruitment_id = $this->recruitment_id;
        $title = $this->title;
        $post = $this->post;
        $number = $this->number;
        $type = $this->type;
        $salary = $this->salary;
        $sex = $this->sex;
        $experience = $this->experience;
        $remark = $this->remark;
        $data = [
            'recruitment_id' => $recruitment_id,
            'title' => $title,
            'post' => $post,
            'number' => $number,
            'type' => $type,
            'salary' => $salary,
            'sex' => $sex,
            'experience' => $experience,
            'remark' => $remark
        ];
        $response = RecruitmentLogic::updateRecruitment($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/recruitment/list",
     *     tags={"Recruitment"},
     *     description="获取招聘列表",
     *     operationId="getRecruitmentList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="cafe_id",
     *         in="query",
     *         description="咖啡馆ID",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="limit",
     *         in="query",
     *         description="分页大小",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Parameter(
     *         name="status",
     *         in="query",
     *         description="显示状态",
     *         required=false,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getRecruitmentList()
    {
        $cafe_id = $this->cafe_id;
        $limit = $this->limit;
        $stauts = $this->status;
        $data = [
            'cafe_id' => $cafe_id,
            'limit' => $limit,
            'status' => $stauts
        ];
        $response = RecruitmentLogic::getRecruitmentList($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/recruitment/getSelectList",
     *     tags={"Recruitment"},
     *     description="获取所有下拉菜单列表",
     *     operationId="getSelectList",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getSelectList()
    {
        $response = RecruitmentLogic::getSelectList();
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }


    /**
     * @SWG\Post(
     *     path="/recruitment/changeStatus",
     *     tags={"Recruitment"},
     *     description="改变招聘信息的显示状态",
     *     operationId="changeStatus",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=true,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="recruitment_id",
     *         in="query",
     *         description="招聘信息ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function changeStatus()
    {
        $recruitment_id = $this->recruitment_id;
        $data = [
            'recruitment_id' => $recruitment_id
        ];
        $response = RecruitmentLogic::changeStatus($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Get(
     *     path="/recruitment/detail",
     *     tags={"Recruitment"},
     *     description="获取招聘信息详情",
     *     operationId="getRecruitmentDetail",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="recruitment_id",
     *         in="query",
     *         description="招聘信息ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function getRecruitmentDetail()
    {
        $recruitment_id = $this->recruitment_id;
        $data = [
            'recruitment_id' => $recruitment_id
        ];
        $response = RecruitmentLogic::getRecruitmentDetail($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }

    /**
     * @SWG\Post(
     *     path="/recruitment/delete",
     *     tags={"Recruitment"},
     *     description="删除招聘信息",
     *     operationId="deleteRecruitment",
     *     produces={"application/json", "application/xml", "text/xml", "text/html"},
     *     @SWG\Parameter(
     *         name="loginSession",
     *         in="query",
     *         description="验证秘钥",
     *         required=false,
     *         type="string"
     *     ),
     *     @SWG\Parameter(
     *         name="recruitment_id",
     *         in="query",
     *         description="招聘信息ID",
     *         required=true,
     *         type="integer",
     *         format="int32"
     *     ),
     *     @SWG\Response(
     *         response=200,
     *         description="pet response"
     *     )
     * )
     */
    public function deleteRecruitment()
    {
        $recruitment_id = $this->recruitment_id;
        $data = [
            'recruitment_id' => $recruitment_id
        ];
        $response = RecruitmentLogic::deleteRecruitment($data);
        if ($response->code){
            return $this->response($response->code, $response->message);
        }
        return $this->response($response->code, $response->message, $response->data);
    }
}